from django.db import models


# Create your models here.
class tb_class(models.Model):
    clz_name = models.CharField(max_length=20, verbose_name='班级名字')

    class Meta:
        db_table = 'tb_class'  # 指数据库表名
        verbose_name = '班级名字'  # 在admin站点中显示的名称

    def __str__(self):
        ''' 定义每个数据对象的显示信息'''
        return self.clz_name


class tb_stu(models.Model):
    stu_name = models.CharField(max_length=20, verbose_name='姓名')
    stu_age = models.IntegerField(default=0, verbose_name='年龄')
    clz = models.ForeignKey(tb_class, on_delete=models.CASCADE, verbose_name='对应班级')

    class Meta:
        db_table = 'tb_stu'  # 指数据库表名
        verbose_name = '姓名'  # 在admin站点中显示的名称

    def __str__(self):
        ''' 定义每个数据对象的显示信息'''
        return self.stu_name
